package org.dromara.utils.utils;

import lombok.RequiredArgsConstructor;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.system.domain.SysUserPost;
import org.dromara.system.mapper.SysUserPostMapper;
import org.dromara.system.service.ISysPostService;
import org.springframework.stereotype.Component;

@RequiredArgsConstructor
@Component
public class UserUtil {

    private final ISysPostService postService;

    private final SysUserPostMapper sysUserPostMapper;
    public String getPostName() {
        Long userId = LoginHelper.getUserId();
        SysUserPost sysUserPost = sysUserPostMapper.selectById(userId);

        if(sysUserPost != null){
            Long postId = sysUserPost.getPostId();
            return postService.selectPostById(postId).getPostName();
        }
        return null;
    }
}
